<include file="Public/head" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<style type='text/css'>
    .rule_config{width:100%;}
    .rule_config  .rc{width:100%;height:50px; line-height:50px;}
    .rule_config  .rc_l{width:10%;float:left;}
    .rule_config  .rc_r{width:80%;text-align:left;}
    .c_input{border: 1px solid #d7d7d7;height: 24px;line-height: 24px;margin: 0 10px 10px 0;text-align: center;width: 150px;}
</style>
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar"  menu="jjr.xjjlgl" />
    <div class="mianR">
        <h3 class="cha">卖车奖励规则配置</h3>
        <div class='rule_config'>
            <h4 class="cha">现金奖励</h4>
            <div class='rc'>
                <div class='rc_l'><b>现金金额</b></div>
                <div class='rc_r'>
                    <input type='text' name='reward_cash' class='c_input' value='{$data.cash}' placeholder='请输入现金金额'> 单位为元
                </div>
                <div class='clear'></div>
            </div>
            <div class='rc'>
                <div class='rc_l'><b>分成比例</b></div>
                <div class='rc_r'>
                    <input type='text' name='agent_cash_per' class='c_input' value='{$data.agent_cash_per}' placeholder='请输入经纪人占比' maxlength="3"> 至&nbsp;&nbsp;
                    <input type='text' name='superior_cash_per' class='c_input' value='{$data.superior_cash_per}' placeholder='请输入上级占比' maxlength="3"> 单位为百分比
                </div>
            </div>
            <div class='rc'>
                <div class='rc_l'><b>开启奖励</b></div>
                <div class='rc_r'>
                    <input type='radio' name="cash_isAward" value="1" <?php echo $data['cash_isAward'] == 1 ? 'checked' : '';?> /> 是
                    <input type='radio' name="cash_isAward" value="0" <?php echo $data['cash_isAward'] == 0 ? 'checked' : '';?>/> 否
                </div>
            </div>
        </div>
        <div class='rule_config'>
            <h4 class="cha">积分奖励</h4>
            <div class='rc'>
                <div class='rc_l'><b>积分</b></div>
                <div class='rc_r'>
                    <input type='text' name='reward_integral' class='c_input' value='{$data.integral}' placeholder='请输入积分数量'>
                </div>
                <div class='clear'></div>
            </div>
            <div class='rc'>
                <div class='rc_l'><b>分成比例</b></div>
                <div class='rc_r'>
                    <input type='text' name='agent_integral_per' class='c_input' value='{$data.agent_integral_per}' placeholder='请输入经纪人占比' maxlength="3"> 至&nbsp;&nbsp;
                    <input type='text' name='superior_integral_per' class='c_input' value='{$data.superior_integral_per}' placeholder='请输入上级占比' maxlength="3"> 单位为百分比
                </div>
            </div>
            <div class='rc'>
                <div class='rc_l'><b>开启奖励</b></div>
                <div class='rc_r'>
                    <input type='radio' name="integral_isAward" value="1" <?php echo $data['integral_isAward'] == 1 ? 'checked' : '';?> /> 是
                    <input type='radio' name="integral_isAward" value="0" <?php echo $data['integral_isAward'] == 0 ? 'checked' : '';?>/> 否
                </div>
            </div>
        </div>
        <div class='rule_config'>
            <h4 class="cha">成长值奖励</h4>
            <div class='rc'>
                <div class='rc_l'><b>成长值</b></div>
                <div class='rc_r'>
                    <input type='text' name='reward_growth' class='c_input' value='{$data.growth}' placeholder='请输入成长值数量'>
                </div>
                <div class='clear'></div>
            </div>
            <div class='rc'>
                <div class='rc_l'><b>分成比例</b></div>
                <div class='rc_r'>
                    <input type='text' name='agent_growth_per' class='c_input' value='{$data.agent_growth_per}' placeholder='请输入经纪人占比' maxlength="3"> 至&nbsp;&nbsp;
                    <input type='text' name='superior_growth_per' class='c_input' value='{$data.superior_growth_per}' placeholder='请输入上级占比' maxlength="3"> 单位为百分比
                </div>
            </div>
            <div class='rc'>
                <div class='rc_l'><b>开启奖励</b></div>
                <div class='rc_r'>
                    <input type='radio' name="growth_isAward" value="1" <?php echo $data['growth_isAward'] == 1 ? 'checked' : '';?> /> 是
                    <input type='radio' name="growth_isAward" value="0" <?php echo $data['growth_isAward'] == 0 ? 'checked' : '';?>/> 否
                </div>
            </div>
        </div>
        <div class="yongBtn">
            <input class="queding confirm" type="button" value="确定">
            <input class="quxiao" type="button" value="返回" onclick="history.back();">
        </div>
    </div>
    <div class="clear"></div>
</div>
<script type="text/javascript">
   $(function(){
       $("input[name='reward_cash']").change(function(){
           var reward_cash = $(this).val();
           if(!/(^[0-9]\d*$)/.test(reward_cash)){
                shibai_alert('红包金额格式不正确');
                return false;
           }
       });
       $("input[name='agent_cash_per']").change(function(){
            var agent_cash_per = $(this).val();
            if (!/^(?:0|[1-9][0-9]?|100)$/.test(agent_cash_per)) {
                shibai_alert('分成比例不正确');
                return false;
            }
            var superior_cash_per = 100 - agent_cash_per;
            $("input[name='superior_cash_per']").val(superior_cash_per);
       });
       $("input[name='superior_cash_per']").change(function(){
            var superior_cash_per = $(this).val();
            if (!/^(?:0|[1-9][0-9]?|100)$/.test(superior_cash_per)) {
                shibai_alert('分成比例不正确');
                return false;
            }
            var agent_cash_per = 100 - superior_cash_per;
            $("input[name='agent_cash_per']").val(agent_cash_per);
       });

       $('.confirm').on('click', function () {
           var reward_cash = $("input[name='reward_cash']").val();
           var agent_cash_per = $("input[name='agent_cash_per']").val();
           var superior_cash_per = $("input[name='superior_cash_per']").val();
           var cash_isAward = $("input[name='cash_isAward']:checked").val();
           var reward_integral = $("input[name='reward_integral']").val();
           var agent_integral_per = $("input[name='agent_integral_per']").val();
           var superior_integral_per = $("input[name='superior_integral_per']").val();
           var integral_isAward = $("input[name='integral_isAward']:checked").val();
           var reward_growth = $("input[name='reward_growth']").val();
           var agent_growth_per = $("input[name='agent_growth_per']").val();
           var superior_growth_per = $("input[name='superior_growth_per']").val();
           var growth_isAward = $("input[name='growth_isAward']:checked").val();
           var post_data = {
               'reward_cash': reward_cash,
               'agent_cash_per': agent_cash_per,
               'superior_cash_per': superior_cash_per,
               'cash_isAward': cash_isAward,
               'reward_integral': reward_integral,
               'agent_integral_per': agent_integral_per,
               'superior_integral_per': superior_integral_per,
               'integral_isAward': integral_isAward,
               'reward_growth': reward_growth,
               'agent_growth_per': agent_growth_per,
               'superior_growth_per': superior_growth_per,
               'growth_isAward': growth_isAward
           }
           $.post("/RewardCashLog/updateRewardRuleConfig", post_data, function (data) {
               if (data.code == 200) {
                   btn_alert('更新成功');
                   return false;
               }
               shibai_alert(data.msg);
           }, "JSON");
       });
   });
</script>
<include file="Public/foot" />
